<template>
    <slot :controller="controller" :store="store" :model="model">
        <div :class="classNames" :id="controlID">
            <div class="control-content app-control-calendar__content">
            <AppCalendarTimeline v-bind="$attrs" :name="model.codeName" :store="store" style="" @click-event="ClickTimelineEvent">
            </AppCalendarTimeline>
            </div>
        </div>
 </slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@CALENDAR}}-calendar/{{spinalCase ctrl.codeName}}-calendar-base.vue.hbs生成
import { AppCalendarTimeline } from '@components/widgets/calendar-timeline';
import { createVNode,render, Ref } from 'vue';   
import CalendarService from '@/core/modules/ctrl-service/calendar-service';
import { AppContextMenuContainer } from '@components/common/context-menu-container';
import { useProps, useBasic, useAction, useController } from './order-calendar-timeline-navigation-calendar-hook';
import { CalendarActionType, ICalendarAbility, ICalendarStore, IParam, IViewLogicInput } from "@/core/interface";

// 输入参数
const props = defineProps(useProps());


// 基础数据
const { controlID, getClassNames, model , useNavParamsBind, useEventBind, handleActionClick, handleComponentAction, handleCtrlInit, handleCtrlAction, handleCtrlDestroy} = useBasic(props);

// emit
const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: CalendarActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: ICalendarAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
  return getClassNames(props);
});

//  日历控制器
const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: ICalendarStore = controller.getStore();

const  { getEvents } = useAction(controller);

onMounted(() => {
    controller.ctrlMounted();
});
onUnmounted(() => {
    controller.ctrlDestroy();
})

const calendar:Ref<IParam | null>= ref(null);

// 时间轴点击事件
const ClickTimelineEvent = (arg: IParam) => {
    controller.onTimeLineClick(arg);
}

</script>